package org.raymond.icloud.common.core.mybatis;

import lombok.extern.slf4j.Slf4j;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
@Slf4j
public class UserIdContext {
    private final static ThreadLocal<Long> currentUserId = new ThreadLocal<>();

    public static void setUserId(Long userId) {
        log.debug("setting userId:" + userId + " to current thread.");
        currentUserId.set(userId);
    }

    public static Long getUserId() {
        return currentUserId.get();
    }

    public static void clear(){
        currentUserId.remove();
    }
}
